home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / text / edit / CedBar.lha / CedBar / FileReq.gc < prev    next >
Text File  |  1999-05-10  |  6KB  |  267 lines

  1. G4C
  2.  
  3. ; FILEREQ.GC - *** THIS IS A COPY OF GUIS:TOOLS/FILEREQ.GC *****
  4. ; A multiselect File Requester with Favourites etc..
  5.  
  6. ; GuiLoad guis:tools/filereq.gc  GuiName Routine Path FavFile  -or
  7. ; GuiOpen filereq.gc  GuiName Routine Path FavFile
  8.  
  9. ; GuiName  - Name of your gui
  10. ; Routine  - Routine in your gui that will be called
  11. ; Path     - (optional) path to open at - if you want..
  12. ; FavFile  - (optional) name of the Favourites file
  13.  
  14. ; ====================================================================
  15.  
  16. ;               Globals
  17.  
  18. ; ====================================================================
  19.  
  20. WINBIG 185 16 291 213 'Choose file(s) :'
  21. WinType 11110001
  22. varpath ''
  23.  
  24. BOX 0 0 291 213 in icondrop
  25.  
  26.  
  27. ; ====================================================================
  28.  
  29. ;               System events
  30.  
  31. ; ====================================================================
  32.  
  33. xONLOAD  gui routine path favfile 
  34.    if  $gui > ''           ; dont pass them if you just want to load it.
  35.    and $routine > ''
  36.        guiopen filereq.gc $gui $routine $path $favfile
  37.    endif
  38.  
  39. xONRELOAD  gui routine path favfile 
  40.    guiopen filereq.gc $gui $routine $path $favfile
  41.  
  42.  
  43. XONOPEN  gui routine path favfile 
  44.    setgad filereq.gc 52/53 off
  45.    if $path > ''
  46.       lvuse filereq.gc 1
  47.       LVDir '#$path'
  48.       update filereq.gc 2 $$lv.dir      
  49.    endif
  50.    if $favfile = ""
  51.       favfile = guis:tools/fav/default
  52.    endif
  53.    
  54.  
  55. xOnRMB
  56.    if $mode = FAV
  57.       setgad filereq.gc 52/53 off
  58.       setgad filereq.gc 2/16 on
  59.       setgad filereq.gc 50/51 on
  60.       lvuse filereq.gc 1
  61.       lvmode DIR
  62.       lvdir #$$lv.dir
  63.       mode = ''
  64.    else
  65.       status
  66.    endif
  67.  
  68.  
  69. ; ====================================================================
  70.  
  71. ;               The Listview
  72.  
  73. ; ====================================================================
  74.  
  75. XLISTVIEW 9 5 213 190 "" filename "" 10 DIR
  76.    GADID 1
  77.    GADFONT #mono 8 000
  78.    if $mode = FAV
  79.       setgad filereq.gc 52/53 off
  80.       setgad filereq.gc 2/16 on
  81.       setgad filereq.gc 50/51 on
  82.       mode = ''
  83.       lvmode DIR
  84.       lvdir #$filename
  85.    else
  86.       guiclose filereq.gc
  87.       gosub $gui $routine $filereq.gc/filename  ; Give FULL variable path!
  88.    endif
  89.  
  90.  
  91. ; directory hook
  92. xlvdirhook 1
  93.    update filereq.gc 2 $filename       
  94.  
  95.  
  96. ; single click hook
  97. xlvhook 1
  98.    update filereq.gc 2 $filename
  99.  
  100.  
  101. XTEXTIN 9 194 273 14 "" txtfile "" 100
  102.    GADID 2
  103.    gadhelp 'Shows file chosen - Change the name & hit enter, to Rename it'
  104.    ifexists file $txtfile
  105.       guiclose filereq.gc
  106.       gosub $gui $routine $filereq.gc/filename
  107.    else
  108.       ezreq 'Rename $filename\nto $txtfile ?' Rename|CANCEL choice
  109.       if $choice = 1
  110.          rename $filename $txtfile
  111.          lvuse filereq.gc 1
  112.          lvdir refresh
  113.       endif
  114.    endif
  115.    
  116.  
  117. ; ====================================================================
  118.  
  119. ;               Listview control buttons
  120.  
  121. ; ====================================================================
  122.  
  123. XBUTTON 224 5 58 14 "Parent"
  124.    gadid 10
  125.    gadhelp 'CD to Parent of current dir'
  126.    lvuse filereq.gc 1
  127.    LVDir parent
  128.    update filereq.gc 2 $$lv.dir      
  129.    
  130.  
  131. XBUTTON 224 19 58 14 "Root"
  132.    gadid 11
  133.    gadhelp 'CD to Root of current dir'
  134.    lvuse filereq.gc 1
  135.    LVDir root
  136.    update filereq.gc 2 $$lv.dir      
  137.    
  138.  
  139. XBUTTON 224 33 58 14 "Disks"
  140.    gadid 12
  141.    gadhelp 'Show device list'
  142.    lvuse filereq.gc 1
  143.    LVDir disks
  144.    update filereq.gc 2 $$lv.dir      
  145.    
  146.  
  147. XBUTTON 224 47 58 14 "All"
  148.    gadid 13
  149.    gadhelp 'Select all items'
  150.    lvuse filereq.gc 1
  151.    LVDir all
  152.    update filereq.gc 2 $$lv.dir      
  153.    
  154.  
  155. XBUTTON 224 61 58 14 "None"
  156.    gadid 14
  157.    gadhelp 'Unselect all items'
  158.    lvuse filereq.gc 1
  159.    LVDir none
  160.    update filereq.gc 2 $$lv.dir      
  161.    
  162. ; ====================================================================
  163.  
  164. ;               Copy & delete
  165.  
  166. ; ====================================================================
  167.  
  168. XBUTTON 224 92 58 14 "Copy"
  169.    gadid 14
  170.    gadhelp 'Copy selected files (destination chosen through requester)'
  171.    dest = ''
  172.    ReqFile -1 -1 300 -40 'Choose destination:' DIR dest ''
  173.    if $dest > ' '
  174.       lvuse filereq.gc 1
  175.       lvaction copy $dest
  176.    endif
  177.    
  178. XBUTTON 224 78 58 14 "Delete"
  179.    gadid 14
  180.    gadhelp 'Delete selected files'
  181.    lvuse filereq.gc 1
  182.    lvaction delete REQ
  183.    
  184. XBUTTON 224 106 58 14 "MkDir"
  185.    gadid 16
  186.    gadhelp 'Create directory named $txtfile'
  187.    guiclose filereq.gc
  188.    ifexists dir $txtfile
  189.    orifexists file $txtfile
  190.       ezreq 'ERROR: Invalid directory name.\n\nEnter valid name for directory\nin the TxtIn gadget and try again..' OK ''
  191.    else
  192.       makedir $txtfile
  193.       lvdir #$txtfile
  194.       update filereq.gc 2 $filename       
  195.    endif
  196.    
  197.  
  198. ; ====================================================================
  199.  
  200. ;               Favourites control
  201.  
  202. ; ====================================================================
  203.  
  204. XBUTTON 224 123 58 14 "Fav"
  205.    gadid 50
  206.    gadhelp 'Shows Favourites listing ($favfile\)'
  207.    setgad filereq.gc 2/16 off
  208.    setgad filereq.gc 50/51 off
  209.    setgad filereq.gc 52/53 on
  210.    lvuse filereq.gc 1
  211.    lvmode MULTI
  212.    lvchange $favfile
  213.    lvsort asc
  214.    mode = FAV
  215.    
  216.  
  217. XBUTTON 224 137 29 14 "+"       ; add to favourites
  218.    gadid 51                        ; create file if it doesn't exist
  219.    gadhelp 'Add current dir to Favourites'
  220.    ifexists file $favfile
  221.       ; ok
  222.    else
  223.       .dummy = 'GUIs:'             ; got to have this one :)
  224.       copy env:.dummy $favfile
  225.    endif
  226.    lvuse filereq.gc 1
  227.    append $favfile '\n$$lv.dir'
  228.    
  229.  
  230. XBUTTON 253 137 29 14 "-"     ; delete from favourites
  231.    gadid 52
  232.    gadhelp 'Deleted selected favourites entries'
  233.    lvuse filereq.gc 1
  234.    lvmulti first
  235.    while $filename > ''
  236.        lvdel -1
  237.        lvmulti first      ; since we deleted the old 1st one
  238.    endwhile
  239.    
  240.  
  241. XBUTTON 224 151 58 14 "Save"  ; save favourites
  242.    gadid 53
  243.    gadhelp 'Save Favourites as $favfile'
  244.    lvuse filereq.gc 1
  245.    lvsave $favfile
  246.    
  247. ; ====================================================================
  248.  
  249. ;               OK & Cancel
  250.  
  251. ; ====================================================================
  252.  
  253. XBUTTON 224 168 58 25 "OK"
  254.    gadid 15
  255.    gadhelp 'Selected files will be sent to calling gui'
  256.    guiclose filereq.gc
  257.    lvuse filereq.gc 1
  258.    lvmulti first
  259.    while $filename > ''
  260.       gosub $gui $routine $filereq.gc/filename
  261.       lvmulti off
  262.       lvmulti next
  263.    endwhile
  264.    
  265.  
  266.  
  267.